Retour vers : Accueil

Sécurisation des services web

>  Sécurité - WS-Security X.509 Certificate Token Profile

>  Sécurité - WS-Security SAML Token Profile / Holder-of-Key

>  Sécurité - TLS Protocol

Les services Web de la plateforme SOA sont sécurisés à deux niveaux. Au niveau du transport, le service consumer doit obligatoirement établir une connexion via le protocole SSL/TLS. Au niveau du message, l'authentification du service consumer s'effectue sur base des certificats X.509.

Les standards WS-Security utilisés sont décrits dans les spécifications suivantes :

Erreur

Lorsque la plateforme SOA n'accepte pas une requête en raison d'une erreur de sécurité, une erreur SOAP avec le code d'erreur suivant est renvoyée : SOA-01001 – Service call not authenticated.

1
2
3
4
5
6
7
8
9
10
11
12
<soapenv:Fault>
 <faultcode>soapenv:Client</faultcode>
 <faultstring>SOA-01001: Service call not authenticated.</faultstring>
  <detail>
   <urn:SystemError Id="Id-361d9c637de72d01a33bb672" xmlns:urn="urn:be:fgov:ehealth:errors:soa:v1">
     <Origin>Consumer</Origin>
     <Code>SOA-01001</Code>
     <Message xml:lang="en">Service call not authenticated.</Message>
     <urn:Environment>Production</urn:Environment>
     </urn:SystemError>
    </detail>
</soapenv:Fault>

Sécurité - WS-Security X.509 Certificate Token Profile

Cette politique de sécurité décrit comment un message SOAP doit être signé avec un certificat X.509 lorsqu'une authentification directe est utilisée entre le service consumer et le service provider.

Le header wsse:Security contient les parties suivantes :

  1. wsse:BinarySecurityToken avec le certificat consumer X.509v3 en notation base64 ;
  2. wsu:Timestamp d'une validité maximale de 5 minutes ;
  3. ds:Signature avec signature numérique sur BST, TMS et soapenv:Body. Chaque bloc est canonisé (Exclusive) et hashé (SHA256) (<DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>).

    La signature même est du type RSA-SHA256 (pour un certificat avec chiffrement RSA - <ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>) ou ECDSA-SHA256 (pour un certificat ECC - <ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha256"/>)

Exemple avec PlatformIntegrationConsumerTest (simplifié)

L'opération checkAccessControl de PlatformIntegrationConsumerTest nécessite un certificat X.509 et une signature. Ce test permet de tester la validité de votre certificat et signature.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
   xmlns:urn="urn:be:fgov:ehealth:platformintegrationconsumertest:v1"
   xmlns:urn1="urn:be:fgov:ehealth:platformintegrationconsumertest:types:v1">
    <soapenv:Header>
        <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
         xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
            <wsse:BinarySecurityToken EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary"
             ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"
             wsu:Id="X509-FC77E2C72083DA8E0F16711753508182856">…rbuk8x3PjISQVjsa1grLPH4lIucCYA==</wsse:BinarySecurityToken>
            <ds:Signature Id="SIG-FC77E2C72083DA8E0F16711753508252860" xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
                <ds:SignedInfo>
                    <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
                        <ec:InclusiveNamespaces PrefixList="soapenv urn urn1"xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#"/>
                    </ds:CanonicalizationMethod>
                    <ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>
                    <ds:Reference URI="#TS-FC77E2C72083DA8E0F16711753508042855">
                        <ds:Transforms>
                            <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
                                <ec:InclusiveNamespaces PrefixList="wsse soapenv urn urn1" xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#"/>
                            </ds:Transform>
                        </ds:Transforms>
                        <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
                        <ds:DigestValue>9Ec830Iy7Z5H+2XOjISfBDxlHmav2B6hRNvrKO/KciY=</ds:DigestValue>
                    </ds:Reference>
                    <ds:Reference URI="#id-FC77E2C72083DA8E0F16711753508182859">
                        <ds:Transforms>
                            <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
                                <ec:InclusiveNamespaces PrefixList="urn urn1" xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#"/>
                            </ds:Transform>
                        </ds:Transforms>
                        <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
                        <ds:DigestValue>IIl2PFRIe6Olae8SjrOKea+sovVPaAmzTTB6Gpa/+kg=</ds:DigestValue>
                    </ds:Reference>
                    <ds:Reference URI="#X509-FC77E2C72083DA8E0F16711753508182856">
                        <ds:Transforms>
                            <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
                                <ec:InclusiveNamespaces PrefixList="" xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#"/>
                            </ds:Transform>
                        </ds:Transforms>
                        <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
                        <ds:DigestValue>MopA8Zl3j+3kSqI0VvpN1DDfrRiN1CmGZomUgx9XNnc=</ds:DigestValue>
                    </ds:Reference>
                </ds:SignedInfo>
                <ds:SignatureValue>...WlQd2a66TRxHw==</ds:SignatureValue>
                <ds:KeyInfo Id="KI-FC77E2C72083DA8E0F16711753508182857">
                    <wsse:SecurityTokenReference wsu:Id="STR-FC77E2C72083DA8E0F16711753508182858">
                        <wsse:Reference URI="#X509-FC77E2C72083DA8E0F16711753508182856"
                         ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"/>
                    </wsse:SecurityTokenReference>
                </ds:KeyInfo>
            </ds:Signature>
            <wsu:Timestamp wsu:Id="TS-FC77E2C72083DA8E0F16711753508042855">
                <wsu:Created>2022-12-16T07:22:30.803Z</wsu:Created>
                <wsu:Expires>2022-12-16T07:23:30.803Z</wsu:Expires>
            </wsu:Timestamp>
        </wsse:Security>
    </soapenv:Header>
    <soapenv:Body wsu:Id="id-FC77E2C72083DA8E0F16711753508182859" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
        <urn:CheckAccessControlRequest>
            <urn1:Message>Hello World</urn1:Message>
            <urn1:Timestamp>2014-12-30T15:29:03.157+01:00</urn1:Timestamp>
        </urn:CheckAccessControlRequest>
    </soapenv:Body>
</soapenv:Envelope>

Sécurité - WS-Security SAML Token Profile / Holder-of-Key

Un grand nombre de services doivent être appelés avec un token SAML reçu par un service central d’authentification : API Portal (indiquez le terme 'IAM-STS-SecurityTokenService' dans le moteur de recherche) en suivant le standard de OASIS WS-Trust.

Le processus d’authentification se passe comme ceci :

  1. Le service client s’authentifie une fois à STS avec un certificat X.509.
  2. Il obtient de STS un token signé SAML qui reste valide pendant une durée limitée.
  3. Avec ce token, le client peut appeler différents webservices pendant la durée de validité du token.

Pour information: le mécanisme de STS doit être implémenté avant de pouvoir appeler un service business.

Étape par étape

Étape 1

Le service consumer envoie un RequestSecurityToken (RST) au STS avec la demande d'obtenir un token SAML 1.1. Le service consumer signe la SOAP request suivant la x.509 _SHA256 security policy.

Exemple RST

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<wst:RequestSecurityToken Context="RC-7150fca4-1999-45b8-8284-a3944409a345" 
    xmlns:auth = "http://docs.oasis-open.org/wsfed/authorization/200706" 
    xmlns:ds = "http://www.w3.org/2000/09/xmldsig#"
    xmlns:wsa = "http://schemas.xmlsoap.org/ws/2004/08/addressing" 
    xmlns:wsp = "http://schemas.xmlsoap.org/ws/2004/09/policy" 
    xmlns:wsse = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd " xmlns:wst=" http : // docs.oasis-open.org/ws-sx/ws-trust/200512"> 
    <wst:TokenType>http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1</wst:TokenType>
    <wst:RequestType>http://docs.oasis-open.org/ws-sx/ws-trust/200512/Issue</wst:RequestType>
    <wst:Claims Dialect="http://docs.oasis-open.org/wsfed/authorization/200706/authclaims">
        <auth:ClaimType Uri="urn:be:fgov:kbo-bce:organization:cbe-number"/>
        <auth:ClaimType Uri="urn:be:fgov:ehealth:1.0:certificateholder:enterprise:cbe-number"/>
    </wst:Claims>
    <wst:KeyType>http://docs.oasis-open.org/ws-sx/wstrust/200512/PublicKey</wst:KeyType>
</wst:RequestSecurityToken>

Étape 2

Après authentification, le STS répondra par une RequestSecurityTokenResponse (RSTR) qui contient le token SAML demandé. La SAML assertion peut être filtrée avec xpath (//soapenv:Body/wst:RequestSecurityTokenResponse/wst:RequestedSecurityToken/*).

Exemple RSTR

1
2
3
4
5
6
7
8
9
10
11
12
13
<wst:RequestSecurityTokenResponse Context = "RC-938ae2a2-6839-41ee-9c0e-7eab62a5a748" xmlns:wst = "http://docs.oasis-open.org/ws-sx/ws-trust/200512" > 
    <wst:RequestedSecurityToken> 
        <Assertion AssertionID = "_4d2f2572befc1c6a70493a35d3618c66" IssueInstant = "2022-12-16T07:46:12.258Z" Issuer = "urn:be:fgov:ehealth:sts:1_0" MajorVersion = "1" MinorVersion = "1"
        xmlns = "urn:oasis:names:tc:SAML:1.0:assertion"> 
            <Conditions NotBefore="2022-12-16T06:25:10.000Z" NotOnOrAfter="2022-12-16T07:30:10.000Z"/> 
            <AuthenticationStatement AuthenticationInstant = "2022-12-16T07:46:12.258Z" AuthenticationMethod = "urn:oasis:names:tc:SAML:1.0:am:X509-PKI" > ...</AuthenticationStatement>
            <AttributeStatement>...</AttributeStatement>
            <ds:Signature xmlns:ds = "http://www.w3.org/2000/09/xmldsig#" >...</ds:Signature>
        </Assertion>
    </wst:RequestedSecurityToken>
</wst:RequestSecurityTokenResponse>

 

Les attributs du token sont évalués durant le contrôle d'accès du service business (autorisation). La structure XML est signée numériquement par le STS pour garantir l'authenticité. Le bloc Conditions indique dans quelle période le token SAML peut être réutilisé par le service consumer.

Étape 3

Avec un token SAML reçu du STS, le consumer peut invoquer plusieurs services business pendant la durée de validité du token.

Le header wsse:Security contient les parties suivantes :

  1. saml:Assertion est le token SAML signé par le STS. Les données xml ne peuvent pas être modifiées (pas de formatage, pas de modifications à l'espace de noms), sans quoi la signature numérique sera cassée.
  2. wsu:Timestamp d'une validité maximale de 5 minutes.
  3. ds:Signature avec signature numérique sur TMS et soapenv:Body. Chaque bloc est canonisé (Exclusive) et haché (SHA-256).

    La signature même est du type :

    RSA-SHA256 (pour un certificat avec chiffrement RSA - <ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>)
    ou 
    ECDSA-SHA256 (pour un certificat ECC - <ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha256"/>).

    Le ds:KeyInfo réfère au saml:Assertion sur la base du AssertionID.
     

Exemple de service business (simplifié)

L'opération checkBrokeredAccess de PlatformIntegrationConsumerTest nécéssite un token SAML de STS. Le but de l'opération est de copier le token SAML précédemment récupéré de l'étape 2 dans la requête vers le webservice business.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<soapenv:Envelope xmlns:soapenv = "http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:be:fgov:ehealth:platformintegrationconsumertest:v1"
xmlns:urn1="urn:be:fgov:ehealth:platformintegrationconsumertest:types:v1"> 
    <soapenv:Header> 
        <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wsswssecurity-
        utility - 1.0.xsd ">
            <Assertion AssertionID="_c0773aaeca35a5e45d14c6a08015fba1" IssueInstant="2022-12-16T08:08:57.482Z"
                       Issuer="urn:be:fgov:ehealth:sts:1_0" MajorVersion = "1"
            MinorVersion="1" xmlns="urn:oasis:names:tc:SAML:1.0:assertion" > 
                <Conditions NotBefore="2022-12-16T08:03:57.466Z" NotOnOrAfter="2022-12-16T09:13:57.466Z"/> 
                <AuthenticationStatement AuthenticationInstant = "2022-12-16T08:08:57.482Z" AuthenticationMethod="urn:oasis:names:tc:SAML:1.0:am:X509-PKI" > ...</AuthenticationStatement>
                <AttributeStatement>...</AttributeStatement>
                <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">...</ds:Signature>
            </Assertion>
            <ds:Signature Id="SIG-FC77E2C72083DA8E0F16711781375072917" xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
                <ds:SignedInfo>
                    <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
                        <ec:InclusiveNamespaces PrefixList="soapenv urn urn1" xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#"/>
                    </ds:CanonicalizationMethod>
                    <ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>
                    <ds:Reference URI="#id-FC77E2C72083DA8E0F16711781375072916">
                        <ds:Transforms>
                            <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
                                <ec:InclusiveNamespaces PrefixList="urn urn1" xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#"/>
                            </ds:Transform>
                        </ds:Transforms>
                        <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
                        <ds:DigestValue>irwe7OSrrEbfPRL5Ah7Jo1T/oux5XNSj6S/H57QDEgI=</ds:DigestValue>
                    </ds:Reference>
                    <ds:Reference URI="#TS-FC77E2C72083DA8E0F16711781373312907">
                        <ds:Transforms>
                            <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
                                <ec:InclusiveNamespaces PrefixList="wsse soapenv urn urn1" xmlns:ec="http://www.w3.org/2001/10/xml-excc14n#"/>
                            </ds:Transform>
                        </ds:Transforms>
                        <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
                        <ds:DigestValue>s3bZR8dkKVkxgQ2E/+c7654gyAH90KVK2BfgYqtUIB4=</ds:DigestValue>
                    </ds:Reference>
                </ds:SignedInfo>
                <ds:SignatureValue>Kc7YG...pRI7A==</ds:SignatureValue>
                <ds:KeyInfo Id="KI-FC77E2C72083DA8E0F16711781375072914">
                    <wsse:SecurityTokenReference wsse11:TokenType="http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1"
                      wsu:Id="STRFC77E2C72083DA8E0F16711781375072915"
                      xmlns:wsse11 = "http://docs.oasis-open.org/wss/oasis-wss-wssecurity-secext-1.1.xsd" > 
                        <wsse:KeyIdentifier ValueType="http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.0#SAMLAssertionID">_c0773aaeca35a5e45d14c6a08015fba1</wsse:KeyIdentifier>
                    </wsse:SecurityTokenReference>
                </ds:KeyInfo>
            </ds:Signature>
            <wsu:Timestamp wsu:Id="TS-FC77E2C72083DA8E0F16711781373312907">
                <wsu:Created>2022-12-16T08:08:57.331 Z</wsu:Created>
                <wsu:Expires>2022-12-16T08:09:57.331Z</wsu:Expires>
            </wsu:Timestamp>
        </wsse:Security>
    </soapenv:Header>
    <soapenv:Body wsu:Id="id-FC77E2C72083DA8E0F16711781375072916" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
        <urn:CheckBrokeredAccessControlRequest>
            <urn1:Message>Hello World</urn1:Message>
            <urn1:Timestamp>2014-12-30T15:29:03.157+01:00</urn1:Timestamp >
        </urn:CheckBrokeredAccessControlRequest>
    </soapenv:Body>
</soapenv:Envelope>

Sécurité - TLS Protocol

Au niveau du transport, le service consumer doit obligatoirement établir une connexion via le protocole TLS. De cette manière, il est certain de l'identité du service provider (plateforme SOA) et les données en transit sont protégées par voie de cryptage.

Les certificats du serveur de la plateforme SOA sont validés par la Sectigo et doivent être acceptés par le service consumer.

Chaining

1
2
3
Sectigo (AAA) 
|_ USERTRUST RSA CERTIFICATION AUTHORITY
    |_GEANT OV RSA CA 4

 

ou

Chaining

1
2
USERtrust RSA Certification Authority (avec le nom amical «SECTIGO») 
|_ |_GEANT OV RSA CA 4

 

Téléchargez le zip avec les certificats Sectigo

Attention : les certificats du serveur sont renouvelés régulièrement. Cela vaut également pour la CA qui délivre les certificats.

Pour information : l'environnement d’acceptation est dédié à l'exécution de tests avant d'utiliser l'environnement de production.

Vous pouvez télécharger les certificats à l'aide d'un navigateur ou via l’openssl-commando:

1
>> openssl s_client -showcerts -connect services.ehealth.fgov.be:443

Exemple avec PlatformIntegrationConsumerTest 

Toute la communication passe par une connexion SSL/TLS. L'opération de base du PlatformIntegrationConsumerTest n'a pas de bloc wsse:Security dans le SOAP header.

1
2
3
4
5
6
7
8
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:be:fgov:ehealth:platformintegrationconsumertest:v1"
xmlns:urn1="urn:be:fgov:ehealth:platformintegrationconsumertest:types:v1">
    <soapenv:Header/>
    <soapenv:Body>
        <urn:CheckConnectionRequest>
            <urn1:Message>Hello World</urn1:Message>
            <urn1:Timestamp>2014-12-30T15:29:03.157+01:00</urn1:Timestamp>
        </urn:CheckConnectionRequest>
    </soapenv:Body>
</soapenv:Envelope